package com.company.project.web;
import com.company.project.core.Result;
import com.company.project.core.ResultGenerator;
import com.company.project.model.ThesisProcess;
import com.company.project.service.ThesisProcessService;
import com.company.project.service.impl.ThesisProcessServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
* Created by CodeGenerator on 2018/10/09.
*/
@RestController
@RequestMapping("/thesis/process")
public class ThesisProcessController {
    @Resource
    private ThesisProcessServiceImpl thesisProcessService;
    //投稿流程
    @RequestMapping(value = "/selectSubmissionprocess",method = RequestMethod.GET)
    public List selectSubmissionprocess(){
        List list = thesisProcessService.selectSubmissionprocess();
        return list;
    }
    /**
     * 修改投稿流程
     * @param thesisProcess
     * @return
     */
    @PostMapping("/updateTP")
    @ResponseBody
    public Result updateTP(@RequestBody ThesisProcess thesisProcess){
        Boolean aBoolean = thesisProcessService.updateTP(thesisProcess);
        return ResultGenerator.genSuccessResult(aBoolean);
    }
    @PostMapping("/add")
    public Result add(ThesisProcess thesisProcess) {
        thesisProcessService.save(thesisProcess);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/delete")
    public Result delete(@RequestParam Integer id) {
        thesisProcessService.deleteById(id);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    public Result update(ThesisProcess thesisProcess) {
        thesisProcessService.update(thesisProcess);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/detail")
    public Result detail(@RequestParam Integer id) {
        ThesisProcess thesisProcess = thesisProcessService.findById(id);
        return ResultGenerator.genSuccessResult(thesisProcess);
    }

    @GetMapping("/list")
    public Result list() {
        List<ThesisProcess> list = thesisProcessService.findAll();
        return ResultGenerator.genSuccessResult(list);
    }
}
